// 店铺费用标准API接口
// @author Wu.Liang
// @date 2025-01-30

import { request } from '@/api/request'
import type { ApiResponse } from '@/types'

// 店铺费用标准相关类型定义
export interface ShopFeeStandardVO {
  id: number
  shopId: number
  shopName: string
  shopCode: string
  feeType: string
  feeTypeName: string
  feeAmount: number
  feeUnit: string
  effectiveDate: string
  expiryDate?: string
  status: number
  statusName: string
  remark?: string
  createTime: string
  updateTime: string
  createBy: number
  updateBy: number
  version: number
  deleted: number
}

// 批量新增费用标准DTO
export interface BatchCreateFeeStandardDTO {
  shopIds: number[]
  feeType: string
  feeAmount: number
  feeUnit: string
  effectiveDate: string
  expiryDate?: string
  status: number
  remark?: string
}

// 费用标准查询参数
export interface FeeStandardQueryParams {
  current?: number
  size?: number
  shopId?: number
  feeType?: string
  status?: number
  minFeeAmount?: number
  maxFeeAmount?: number
  effectiveDateStart?: string
  effectiveDateEnd?: string
  expiryDateStart?: string
  expiryDateEnd?: string
  createTimeStart?: string
  createTimeEnd?: string
  keyword?: string
}

// 分页结果
export interface FeeStandardPageResult {
  records: ShopFeeStandardVO[]
  total: number
  current: number
  size: number
}

// 店铺费用标准API
export const shopFeeStandardApi = {
  /**
   * 批量新增费用标准
   * 遵循《Element Plus组件编码规范权威标准声明.md》规范
   * 遵循《系统状态枚举权威标准声明.md》规范
   */
  batchCreate: (data: BatchCreateFeeStandardDTO): Promise<ApiResponse<number[]>> => {
    return request({
      url: '/api/region/shop-fee-standards/batch',
      method: 'POST',
      data
    })
  },

  /**
   * 分页查询费用标准
   * 遵循《Element Plus组件编码规范权威标准声明.md》规范
   */
  getPage: (params: FeeStandardQueryParams): Promise<ApiResponse<FeeStandardPageResult>> => {
    return request({
      url: '/api/region/shop-fee-standards/page',
      method: 'GET',
      params
    })
  },

  /**
   * 获取费用标准详情
   * 遵循《Element Plus组件编码规范权威标准声明.md》规范
   */
  getDetail: (id: number): Promise<ApiResponse<ShopFeeStandardVO>> => {
    return request({
      url: `/api/region/shop-fee-standards/${id}`,
      method: 'GET'
    })
  },

  /**
   * 更新费用标准
   * 遵循《Element Plus组件编码规范权威标准声明.md》规范
   */
  update: (id: number, data: BatchCreateFeeStandardDTO): Promise<ApiResponse<boolean>> => {
    return request({
      url: `/api/region/shop-fee-standards/${id}`,
      method: 'PUT',
      data
    })
  },

  /**
   * 删除费用标准
   * 遵循《Element Plus组件编码规范权威标准声明.md》规范
   */
  delete: (id: number): Promise<ApiResponse<boolean>> => {
    return request({
      url: `/api/region/shop-fee-standards/${id}`,
      method: 'DELETE'
    })
  },

  /**
   * 批量删除费用标准
   * 遵循《Element Plus组件编码规范权威标准声明.md》规范
   */
  batchDelete: (ids: number[]): Promise<ApiResponse<boolean>> => {
    return request({
      url: '/api/region/shop-fee-standards/batch',
      method: 'DELETE',
      data: ids
    })
  }
}
